package com.visionarysoftwaresolutions



import grails.test.mixin.*
import org.junit.*

/**
 * See the API for {@link grails.test.mixin.domain.DomainClassUnitTestMixin} for usage instructions
 */
@TestFor(Tshirt)
class TshirtTests {

    void testInvalidTShirtSize() {
       def shirt = new Tshirt(name:"fake", 
                              description:"blah",
                              price:new BigDecimal(5),
                              size:"wrong",
                              color:"green"
                             )
       mockForConstraintsTests(Tshirt, [shirt])
       assert !shirt.validate()
       assert "inList" == shirt.errors["size"]
    }
    
    void testInvalidTShirtColor() {
       def shirt = new Tshirt(name:"fake", 
                              description:"blah",
                              price:new BigDecimal(5),
                              size:"S",
                              color:"black"
                             )
       mockForConstraintsTests(Tshirt, [shirt])
       assert !shirt.validate()
       assert "inList" == shirt.errors["color"]
    }
    
    void testValidTShirt() {
       def shirt = new Tshirt(name:"fake", 
                              description:"blah",
                              price:new BigDecimal(5),
                              size:"S",
                              color:"Yellow"
                             )
       mockForConstraintsTests(Tshirt, [shirt])
       assert shirt.validate()
    }
}
